package com.ns.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ns.dao.VCommonAreaDao;
import com.ns.dao.VExampaperPartDao;
import com.ns.dao.VMultiQuestionDao;
import com.ns.dao.model.VCommonArea;
import com.ns.dao.model.VExampaperPart;
import com.ns.dao.model.VMultiQuestion;

@Service
@Transactional
public class DataInitService {
	@Autowired
	private VCommonAreaDao areaDao;
	@Autowired
	private VExampaperPartDao partDao;
	@Autowired
	private VMultiQuestionDao multiDao;
	
	
	public Map<Integer,String> findAllAreas(){
		Map<Integer,String> map = new HashMap<Integer,String>();
		List<VCommonArea> tmp = areaDao.findAll();
		for(VCommonArea area:tmp){
			map.put(area.getPukey(), area.getName());
		}
		map.put(-9, "国家");
		return map;
	}
	
	public Map<Integer,String> findAllPart(){
		Map<Integer,String> map = new HashMap<Integer,String>();
		List<VExampaperPart> tmp = partDao.findAll();
		for(VExampaperPart part:tmp){
			map.put(part.getPukey(), part.getName());
		}
		return map;
	}
	
	public Map<Integer,String> findAllMulti(){
		Map<Integer,String> map = new HashMap<Integer,String>();
		List<VMultiQuestion> tmp = multiDao.findAll();
		for(VMultiQuestion q : tmp){
			map.put(q.getPukey(), q.getStem());
		}
		return map;
	}
}
